package com.yanqu.road.server.cmd.wingroom;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/2/23 11:34
 */
@Cmd(code = CrossProtocol.C_WING_ROOM_VISIT_OTHER_PLAYER, desc = "跨服拜访其他玩家厢房")
public class WingRoomWatchOtherPlayerCrossCmd extends CrossCommand {
    private long otherPlayerServerId;
    private long otherPlayerUserId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.WatchOtherPlayerReqMsg msg = WingRoomProto.WatchOtherPlayerReqMsg.parseFrom(packet.getBytes());
        otherPlayerServerId = msg.getOtherPlayerServerId();
        otherPlayerUserId = msg.getOtherPlayerUserId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WingRoomProto.CrossWatchOtherPlayerReqMsg.Builder reqMsg = WingRoomProto.CrossWatchOtherPlayerReqMsg.newBuilder();
        reqMsg.setOriginServerId(serverId);
        reqMsg.setOriginPlayerId(packet.getPlayerId());
        reqMsg.setWatchPlayerId(otherPlayerUserId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_WING_ROOM_CROSS_WATCH_REQ, reqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
